<template>
	<view class="content">
		<workcard :data="cardDetail" @handleSeal="handleSeal"/>
		
		<view class="certificateinfo-container bottom-box">
			<view class="else-info"><text @click="goGX()" class="blue">{{cardDetail.company_name}}</text> 制</view>
		</view>
		
		<bottom-sheet :isShowBottom="isShowBottom" @closeBottom="closeBottom" :data="cardDetail"></bottom-sheet>
	</view>

</template>

<script>
	import workcard from '@/components/workcard/index.vue'
	import bottomSheet from '@/components/bbh-sheet/bottomSheet.vue'
	export default {
		components: {
			workcard,
			bottomSheet
		},
		data() {
			return {
				id: '',
				cardDetail: {},
				user_id: '',
				isShowBottom: false,
				bid: ''
			}
		},
		onLoad: function(e) {
			this.id = e.id || '29'
			//#ifdef MP
				this.user_id = e.user_id || ''
				let ctid = e.ctid || ''
				if (ctid) {
					uni.setStorageSync('ctid', ctid);
				}
				this.getCertificate()
			//#endif
			
			//#ifdef H5
				this.cardDetail = {
					card_content_one: "市场营销总监",
					card_content_three: "A2-11",
					card_content_two: "厦门中盾安信科技有限公司",
					card_explain: '该证件仅供2020年"互联网之光"博览会体验演示使用，过期失效。',
					card_key_one: "职务",
					card_key_three: "展位号",
					card_key_two: "单位",
					card_name: "展会参展证",
					company_name: "厦门中盾安信科技有限公司",
					company_seal: "/h5/static/images/seal_example.png",
					company_url: "https://yymobile.gxzg.org.cn/detail/659001126149855",
					failure_ts: "2020-11-25 08:10:10",
					flow_info: {
						contractUser: "厦门中盾安信科技有限公司",
						isTimeStamp: true,
						isVerify: true,
						organization: "C=CN,O=iTrusChina，OU=China Trust Network，CN=iTrusChina Class 2 Enterprise Subscriber",
						signDate: "2020-11-20 08:10:10",
						timeStamp: "2020-11-20 08:10:10",
						verifies: true
					},
					gx_company_id: "659001126149855",
					id: 29,
					nick_name: "小林",
					phone: "",
					status_name: "已生效",
					user_pic: "/h5/static/images/photo_example.png",
					work_card_id: "160570049747",
					work_way: "邀请申领",
				}
			//#endif
			
		},
		methods: {
			getCertificate() {
				let param = {
					id: parseInt(this.id) || 0,
					user_id: this.user_id ? parseInt(this.user_id) : 0
				}
				this.$HTTP.post('/work_permit_card/cert_info', param, true).then((res) => {
					this.cardDetail = res.data
				}).catch(err => {
				
				})  
			},
			closeBottom() {
				this.isShowBottom = false
			},
			handleSeal() {
				this.isShowBottom = true
			},
			/**
			 * 跳转到公信
			 */
			goGX() {
				if (this.cardDetail.gx_company_id == '0'){
					return false
				}
				// 只有在h5编译
				//#ifdef H5
				if(this.id == 'h5show') {
					window.location.href = 'http://m.gxzg.org.cn/detail/659001128803619'
				}
				//#endif
				// 只有在小程序编译
				//#ifdef MP
				// 跳转公信小程序
				 uni.navigateToMiniProgram({
				   appId: 'wx8369661ce0151897',
				   path: 'pages/companyDetail/index?id=' + this.cardDetail.gx_company_id,
				   extraData: {
				     'data1': 'test'
				   },
				   envVersion: 'trial',
				   success(res) {
				     // 打开成功
				   }
				 })
				//#endif
			}
		}


	}
</script>
<style lang="scss" scoped>
	@import "./index.scss";
</style>
<style lang="scss">
	page{
		background-color: #f8f8f8;
	}
</style>